package ${cfg.basePackage}.module.controller;

import ${cfg.basePackage}.mybatis.gen.entity.${entity};
import ${cfg.basePackage}.common.project.SRS;
import ${cfg.basePackage}.common.project.annotation.Auth;
import ${cfg.basePackage}.common.project.annotation.Doc_C;
import ${cfg.basePackage}.common.project.annotation.Doc_M;
import ${cfg.basePackage}.common.project.enums.AuthType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Doc_C(ability = "${table.comment!}控制器", author = {"${author}"}, time = "${cfg.date}")
@RestController
@RequestMapping("/${table.entityPath}/${table.entityPath}")
@Auth(auth = AuthType.PUBLIC)
public class ${entity}Ctr {
    @Autowired
    ${entity}Ser ${table.entityPath}Ser;

    /**
     * 这里是注意事项，与注解使用说明,看后删除即可
     * <p>
     * 注意： System.out.println() 和 无用的 log 记得删除或者注释
     * 注意: BaseSer中的工具类，在 SerImpl中直接 .() 调用
     *
     * <p>
     * Doc_M --- 必须写
     * <p>
     *
     * @Auth --- 根据情况写
     * 【Doc_P，Doc_Ps，Doc_P_E】 可以不写，选只能选一个
     * 【Doc_R，Doc_Rs，Doc_R_E】 可以不写，选只能选一个
     * <p>
     * @Auth(auth = AuthType.PUBLIC) ---权限
     * <p>
     * @Doc_M(ability = "添加数据", author = {"王永吉"}) --- 方法描述
     * <p>
     * @Doc_P(key = "Key", value = "参数", required = true) --- 单一参数
     * <p>
     * //参数列表
     * @Doc_Ps({
     * @Doc_P(key = "Key1", value = "参数1"),
     * @Doc_P(key = "Key2", value = "参数2")
     * })
     * <p>
     * @Doc_R(key = "Key", value = "返回值") --- 单一返回值
     * <p>
     * //返回值列表
     * @Doc_Rs({
     * @Doc_R(key = "Key1", value = "返回值1"),
     * @Doc_R(key = "Key2", value = "返回值2")
     * })
     * <p>
     * //返回值内容
     * @Doc_R_E("{\n" +
     * " \"code\": 200,\n" +
     * " \"data\": {},\n" +
     * " \"success\": true,\n" +
     * " \"message\": \"操作完成.\"\n" +
     * "}")
     * <p>
     * //参数内容
     * @Doc_P_E("{\n" +
     * " \"name\": 张三,\n" +
     * " \"message\": \"测试测试.\"" +
     * "}")
     * <p>
     * <p>
     * @Doc_M(ability = "添加数据", author = {"王永吉"})
     * @RequestMapping({"/insert"}) //
     * public SRS add(@RequestBody ${entity} ${table.entityPath}) {
     * return ${table.entityPath}Ser.insert(${table.entityPath});
     * }
     */

    @Doc_M(ability = "添加数据", author = {"王永吉"})
    @Auth(auth = AuthType.PUBLIC)
    @RequestMapping({"/insert"})
    public SRS add(@RequestBody ${entity} ${table.entityPath}) {
    return ${table.entityPath}Ser.insert(${table.entityPath});
    }

    @Doc_M(ability = "删除数据", author = {"王永吉"})
    @RequestMapping({"/delete"})
    public SRS delete(@RequestBody Long[] ids) {
    return ${table.entityPath}Ser.delete(ids);
    }

    @Doc_M(ability = "修改数据", author = {"王永吉"})
    @RequestMapping({"/update"})
    public SRS update(@RequestBody ${entity} ${table.entityPath}) {
    return ${table.entityPath}Ser.update(${table.entityPath});
    }

    @Doc_M(ability = "列表查询", author = {"王永吉"})
    @RequestMapping({"/list"})
    public SRS list(@RequestBody ${entity} ${table.entityPath}) {
    return ${table.entityPath}Ser.list(${table.entityPath});
    }

    @Doc_M(ability = "分页查询", author = {"王永吉"})
    @RequestMapping("/page")
    public SRS page(@RequestBody SRS param) {
    return ${table.entityPath}Ser.page(param);
    }

    @Doc_M(ability = "查询一条数据", author = {"王永吉"})
    @RequestMapping("/one")
    public SRS one(@RequestBody SRS param) {
    return ${table.entityPath}Ser.one(param);
    }
}
